#include <ctime>
#include "threadpool.hpp"
#include "task.hpp"

int main()
{
    //ThreadPool<Task>* tp = new ThreadPool<Task>(5);
    //tp->Run();
    std::cout << "Process is running..." << std::endl;
    ThreadPool<Task>::GetInstance()->Run();
    while(true)
    {
        // 创建任务
        int x = rand() % 10 + 1;
        usleep(10);
        int y = rand() % 5;
        char op = opers[rand() % opers.size()];
        sleep(1);
        Task t(x, y, op);
        ThreadPool<Task>::GetInstance()->Push(t);
        // 任务交给线程池处理
        std::cout << "main thread make a task: " << t.GetTask() << std::endl;
    }

    return 0;
}